<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="../ajile/com.iskitz.ajile.js?mvcoff,mvcshareoff,refresh"></script>
<script type="text/javascript" src="../gdataloader/org.wattdepot.gdata.GDataLoader.js"></script>
<script type="text/javascript" src="org.wattdepot.gdata.makahiki.EnergyRank.js"></script>
</head>

<body>
  <h2>Info for Lehua-A</h2>
  <div id="header-rank">
    <h3 style="display:inline" id="rank"></h3> out of 15 lounges in all dorms.
  </div>
  <div id="header-energy">
    <h3 style="display:inline" id="energy"></h3> kWh used today.
  </div>
  
  <h2>Standings for today</h2>
  <div id="current-leader">
    Current Leader: <span id="leader"></span>
  </div>
  
  <div id="complete-standings">
    <h3>This is for dorms with data</h3>
    <table id="partial-standings-table">
    </table>
    
    <h3>These are the complete standings</h3>
    <table id="full-standings-table">
    </table>
  </div>
</body>

 
<script type="text/javascript">
// Wrap this code in an anonymous self-invoking function to avoid polluting global namespace.
(function() {
  // Get the spreadsheet we need.
  var energyLastThirtyDays = "https://spreadsheets.google.com/spreadsheet/tq?key=0An9ynmXUoikYdGNBUHFNdThYUXBMRTY4T2Q5LTRxZGc";
  var refreshInterval = 0; // don't refresh this spreadsheet.

  // Load the visualization API and the spreadsheet, then call displayRank.
  var loader = new org.wattdepot.gdata.GDataLoader(displayRank, energyLastThirtyDays, refreshInterval);  

  function displayRank(energyDataTable) {
    // The source for which we want to find the rank must be specified by Makahiki.
    var source = "Lehua-A";
    var energyRank = new org.wattdepot.gdata.makahiki.EnergyRank();
    var usage = energyRank.processDataTable(energyDataTable, 0, 0);
    // console.log("Leader is " + energyRank.calculateLeader(usage).source);
    var info = energyRank.calculateRankInfo(usage, source);
    // console.log(source + " is ranked " + info.rank + " with " + info.usage + " watts");
    
    energyRank.draw("rank", "energy", info);
    energyRank.insertLeader("leader", energyRank.calculateLeader(usage));
    energyRank.drawCompleteStandings("partial-standings-table", source, usage, true);
    energyRank.drawCompleteStandings("full-standings-table", source, usage);
  }
})();
</script>

</html>








